﻿<Window x:Class="Tum.PDE.LanguageDSL.Visualization.View.Forms.DataTemplatePresetsPopup"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Templates" Height="600" Width="800"
        xmlns:conv="clr-namespace:Tum.PDE.LanguageDSL.Visualization.Converters"
        xmlns:att="clr-namespace:Tum.PDE.LanguageDSL.Visualization.Attached"
        xmlns:avedit="clr-namespace:Tum.PDE.LanguageDSL.Visualization.View.Forms"
        WindowStyle="SingleBorderWindow" WindowStartupLocation="CenterOwner">

    <Window.Resources>
        <ResourceDictionary>
            <conv:MenuIconConverter x:Key="MenuIconUrlConv"/>

            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" x:Key="BorderColor">
                <GradientStop Color="#FFBBD7F6" Offset="0"/>
                <GradientStop Color="#FFE5E8EC" Offset="1"/>
            </LinearGradientBrush>

            <DataTemplate x:Key="DCItemTemplate">
                <Border Width="120" Height="90" BorderThickness="1" BorderBrush="Silver" Margin="5">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="55"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                        <Image Margin="5" Source="{Binding Path=ImageUri}" Width="48" Height="48"
                               HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform"
                               Grid.Row="0"/>

                        <TextBlock TextOptions.TextFormattingMode="Display" TextTrimming="CharacterEllipsis" 
                               Text="{Binding Path=DisplayName, Mode=OneWay}" TextAlignment="Center"
                               ToolTip="{Binding Path=DisplayName, Mode=OneWay}"
                               HorizontalAlignment="Center" VerticalAlignment="Center" TextWrapping="WrapWithOverflow"
                               Grid.Row="1"/>
                    </Grid>
                </Border>
            </DataTemplate>

        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="125"/>
            <RowDefinition Height="30"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ListBox Grid.Row="0" ItemTemplate="{StaticResource DCItemTemplate}" ItemsSource="{Binding Path=TemplateVMs, Mode=OneWay}"
                 SelectedItem="{Binding Path=SelectedTemplateVM, Mode=TwoWay}" SelectionChanged="ListBox_SelectionChanged">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>

        <StackPanel Grid.Row="1" Orientation="Vertical" OpacityMask="#FFA33939">
            <Border Height="3" Background="{StaticResource BorderColor}"/>
            <StackPanel Grid.Row="1" Orientation="Horizontal">
                <TextBlock Margin="5" Text="Selected template: " />
                <TextBlock Margin="5" Text="{Binding Path=SelectedTemplateVM.DisplayName, Mode=OneWay}"/>
            </StackPanel>
            <Border Height="3" Background="{StaticResource BorderColor}"/>
        </StackPanel>

        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <TextBlock Grid.Row="0" Text="{Binding Path=SelectedTemplateVM.DisplayName, Mode=OneWay}" FontWeight="Bold" FontSize="14" Margin="5" TextTrimming="CharacterEllipsis"/>
            <TextBlock Grid.Row="1" Text="{Binding Path=SelectedTemplateVM.Description, Mode=OneWay}" Margin="5" TextWrapping="WrapWithOverflow"/>

            <DockPanel Grid.Row="2">
                <ToolBar DockPanel.Dock="Top">
                    <Button Click="ButtonCopy_Click">
                        <Image Source="pack://application:,,,/Tum.PDE.LanguageDSL.Visualization;component/Resources/Images/Copy.png" Height="16"/>
                    </Button>
                </ToolBar>
                <avedit:PDETextEditor x:Name="pdeTextEditor" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
                                  BindableSyntaxHighlighting="{Binding Path=SelectedTemplateVM.SyntaxHighlighting}"
                                  BindableText="{Binding Path=SelectedTemplateVM.DataTemplate}"/>
            </DockPanel>
            
        </Grid>
    </Grid>
</Window>
